﻿using System;
using System.Collections.Generic;
using SharpSqlAnalyzer.nodes;
using SharpSqlAnalyzer.pp.processor.type.comm;
using SharpSqlAnalyzer.pp.utils;
using SharpSqlAnalyzer.stmt;

namespace SharpSqlAnalyzer.pp.processor.type.insert
{
	// Token: 0x0200023E RID: 574
	public class InsertKeyWordAlignProcessor : AbstractKeyWordAlignProcessor
	{
		// Token: 0x060012F2 RID: 4850 RVA: 0x0031BAB8 File Offset: 0x00319CB8
		protected internal override IList<TSourceToken[]> getTSourceToken<E>(E arg)
		{
			TInsertSqlStatement tinsertSqlStatement = arg as TInsertSqlStatement;
			IList<TSourceToken[]> list = new List<TSourceToken[]>();
			TSourceToken insertToken = tinsertSqlStatement.InsertToken;
			if (insertToken == null)
			{
				return list;
			}
			TSourceToken tsourceToken = SourceTokenSearcher.forwardSearch(insertToken, 3, "all");
			TSourceToken tsourceToken2 = SourceTokenSearcher.forwardSearch(insertToken, 3, "first");
			if (tsourceToken != null || tsourceToken2 != null)
			{
				if (tsourceToken != null)
				{
					list.Add(new TSourceToken[]
					{
						insertToken,
						tsourceToken
					});
				}
				if (tsourceToken2 != null)
				{
					list.Add(new TSourceToken[]
					{
						insertToken,
						tsourceToken2
					});
				}
				if (tinsertSqlStatement.InsertIntoValues != null)
				{
					for (int i = 0; i < tinsertSqlStatement.InsertIntoValues.Count; i++)
					{
						TInsertIntoValue tinsertIntoValue = tinsertSqlStatement.InsertIntoValues[i];
						if (tinsertIntoValue.TargetList != null)
						{
							TSourceToken tsourceToken3 = SourceTokenSearcher.backforwardSearch(tinsertIntoValue.TargetList.startToken, 3, "values");
							if (tsourceToken3 != null)
							{
								list.Add(new TSourceToken[]
								{
									tsourceToken3
								});
							}
						}
					}
				}
			}
			else
			{
				TSourceToken tsourceToken4 = SourceTokenSearcher.forwardSearch(insertToken, 3, "into");
				TSourceToken tsourceToken5 = SourceTokenSearcher.forwardSearch(insertToken, 3, "overwrite");
				if (tsourceToken4 != null)
				{
					list.Add(new TSourceToken[]
					{
						insertToken,
						tsourceToken4
					});
				}
				else if (tsourceToken5 != null)
				{
					list.Add(new TSourceToken[]
					{
						insertToken,
						tsourceToken5
					});
				}
				else
				{
					list.Add(new TSourceToken[]
					{
						insertToken
					});
				}
				if (tinsertSqlStatement.OutputClause != null)
				{
					TSourceToken startToken = tinsertSqlStatement.OutputClause.startToken;
					list.Add(new TSourceToken[]
					{
						startToken
					});
				}
				if (tinsertSqlStatement.WhereClause != null)
				{
					TSourceToken startToken2 = tinsertSqlStatement.WhereClause.startToken;
					list.Add(new TSourceToken[]
					{
						startToken2
					});
				}
				if (tinsertSqlStatement.Values != null)
				{
					TSourceToken tsourceToken6 = SourceTokenSearcher.backforwardSearch(tinsertSqlStatement.Values.startToken, 3, "values");
					if (tsourceToken6 != null)
					{
						list.Add(new TSourceToken[]
						{
							tsourceToken6
						});
					}
				}
			}
			return list;
		}
	}
}
